Component({
    properties: {},
    data: {
        tab: {
            active: 0,
            list: [
                {
                    name: '首页',
                    icon: 'home',
                    url: '/pages/home/index',
                    isDevice: false
                },
                {
                    name: '社区',
                    icon: 'device',
                    url: '/community/pages/home/index',
                    isDevice: false
                },
                {
                    name: '商城',
                    icon: 'shop',
                    url: '/shop/pages/home/index',
                    isDevice: false
                },
                {
                    name: '我的',
                    icon: 'my',
                    url: '/mine/pages/home/index',
                    isDevice: false
                }
            ]
        },
    },
    lifetimes: {
        attached() {
        },
        detached() {
        },
    },
    methods: {
        stopScroll(){return},
        handlerTab(e) {
            const {index, item} = e.currentTarget.dataset
            if (item.url =='/mine/pages/home/index') {
                this.hiddenModal()
                console.log('chongfudianji');
                return
            } else {
                this.hiddenModal()
                wx.redirectTo({url: item.url})
            }
            // if (item.url =='/mine/pages/home/index') {
            //     this.hiddenModal()
            //     console.log('chongfudianji');
            //     return
            // } else if (item.url =='/community/pages/home/index') {
            //     wx.showToast({
            //         title: '正在开发，敬请期待',
            //         icon: 'none',
            //         duration: 3000
            //       })
            // } else if (item.url =='/shop/pages/home/index') {
            //     wx.showToast({
            //         title: '正在开发，敬请期待',
            //         icon: 'none',
            //         duration: 3000
            //       })
            // } else {
            //     this.hiddenModal()
            //     wx.redirectTo({url: item.url})
            // }
            this.data.tab.active = index
            this.data.tab.list.map((item, idx) => {
                if (idx == index) {
                    if (index == 1) {
                        // item.isDevice = !item.isDevice
                    } else {
                        // item.isDevice = true
                        // this.data.tab.list[1].isDevice = false
                    }
                    return
                }
            })
            this.setData({
                tab: this.data.tab
            })
        },
        hiddenModal() {
            this.setData({
                'tab.list[1].isDevice': false
            })
        }
    }
})
